{{extend "req_layout.html"}}

{{block content_main}}
{{use "jquery", css_only=True}}
{{use "jqutils"}}
{{use "jqeasyui"}}
<div class="content">
    <div class="box box-panel">
        <h2>准开发需求查看</h2>
        <div class="box-body">
            {{embed view}}
            <div class="box-bottom">
            {{if request.user.is_superuser:}}
            <a class="btn btn-green" href="/requirements/{{=object.id}}/transfer">迁移</a>
            {{pass}}
            {{if object.can_modified(request.user):}}
            <a class="btn btn-green" href="/requirements/{{=object.id}}/edit">编辑</a>
            {{pass}}
            {{if has_role(request.user,'selfdev_manager') and object.selfdev_if:}}
            <a class="btn btn-green" id="selfdev_modified" href="#">不参与系统自主率考核</a>
            {{pass}}
            {{if has_role(request.user,'selfdev_manager') and not object.selfdev_if:}}
            <a class="btn btn-green" id="selfdev_modified" href="#">参与系统自主率考核</a>
            {{pass}}
            <script type="text/javascript">
            $(function(){
                    $('#selfdev_modified').click(function(event){
                        event.preventDefault();
                        $.ajax({
                            type: "POST",
                            data: {resource:'requirement', object_id:{{=object.id}}},
                            url: "/selfdevs/selfdev_if/modified",
                            success: function(data){
                                show_message(data.msg);
                                if(data.selfdev_modified){
                                    $('#selfdev_modified').html(data.selfdev_modified);
                                    }
                                if(data.selfdev_if){
                                    $('#selfdev_if').html(data.selfdev_if);
                                }
                            }
                        });
                    });
                    
                });
            </script>
            {{if (request.user.users_systems.has(object._main_sys_) or request.user.is_superuser or (request.user.department == '1' and request.user.is_gm and object._tx_ == request.user._tx_)) and (object.stage!='FN'):}}
            <a class="btn btn-blue" href="/requirements/{{=object.id}}/newstage">进入下一阶段</a>
            {{pass}}
            {{if request.user.is_superuser or (request.user.department == '1' and request.user.is_gm and object._tx_ == request.user._tx_):}}
            <a class="btn btn-blue"  href="/requirements/{{=object.id}}/delete" onclick="return confirm('确定要删除当前记录吗？');">删除</a>
            {{pass}}
            <a class="btn btn-green" href="/tasks/develop/list?requirement={{=object.id}}" target="_blank">查看开发任务</a>
            <!-- <a class="btn btn-green" href="/tasks/researches/list?requirement={{=object.id}}" target="_blank">查看可研任务</a> -->
            <a class="btn btn-green" href="/tasks/nondevelop/list?requirement={{=object.id}}" target="_blank">查看非开发任务</a>
            <a class="btn btn-green" href="/weekreport/view?requirement={{=object.id}}">周报查看</a>
            </div>
        </div>
    </div>
    <div class="box box-panel">
    <h2>已完成阶段明细</h2>
    <div id="details" class="box-body"></div>
    <script type="text/javascript">
    $(function(){
        <!--$('#details').load("/requirements/{{=object.id}}/details");-->
        $.ajax({
            type: "POST",
            url: "/requirements/{{=object.id}}/details",
            success: function(data){
            $('#details').html(data);
            }
        });
        
    });
    </script>
    </div>
    <a href="#" name="changes"></a>
    <div class="box box-panel">
        <h2>需求方案变更跟踪</h2>
        <div id="changes" class="box-body">
            <div class="box-bottom">
            {{if object.can_modified(request.user):}}
            <a class="btn btn-green" href="/requirements/changes/{{=object.id}}/add">添加变更说明</a>
            {{pass}}
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(function(){
        $.ajax({
            type: "POST",
            url: "/requirements/changes/{{=object.id}}",
            success: function(data){
            $('#changes').prepend(data);
            }
        });
    });
    </script>
    <a href="#" name="questions"></a>
    <div class="box box-panel">
        <h2>问题跟踪</h2>
        <div id="questions" class="box-body">
            <div class="box-bottom">
            {{#if object.can_modified(request.user):}}
            <a class="btn btn-green" href="/ticket/questions/add?requirement={{=object.id}}">新问题</a>
            {{#pass}}
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(function(){
        $.ajax({
            type: "POST",
            url: "/ticket/questions/list?requirement={{=object.id}}&type=json",
            success: function(data){
            $('#questions').prepend(data.table);
            $('#question_table').datagrid({height:Math.min(22+23*(data.total+1), 300)});
            }
        });
    });
    </script>
    <a href="#" name="risks"></a>
    <div class="box box-panel">
        <h2>风险跟踪</h2>
        <div id="risks" class="box-body">
            <div class="box-bottom">
            {{#if object.can_modified(request.user):}}
            <a class="btn btn-green" href="/ticket/risks/add?requirement={{=object.id}}">新风险</a>
            {{#pass}}
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(function(){
        $.ajax({
            type: "POST",
            url: "/ticket/risks/list?requirement={{=object.id}}&type=json",
            success: function(data){
            $('#risks').prepend(data.table);
            $('#risk_table').datagrid({height:Math.min(22+23*(data.total+1), 300)});
            }
        });
    });
    </script>
</div>
<br/>

{{end}}
